<?php

/**
 * categoria actions.
 *
 * @package    personalts
 * @subpackage categoria
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class categoriaActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executePortafolio(sfWebRequest $request)
  {
    $this->categories = Doctrine_Core::getTable('Categoria')
      ->createQuery('a')
      ->execute();
	$this->categoria_actual = Doctrine_Core::getTable('Categoria')->find(array('1'));
	$this->forward404Unless($this->categoria_actual);

	$this->pager = new sfDoctrinePager('Dibuix', sfConfig::get('app_max_dibuixos_on_categoria'));
	$this->pager->setQuery($this->categoria_actual->getDibuixosQuery());
	$this->pager->setPage($request->getParameter('page', 1));
	$this->pager->init();
	
	$this->dibuixos = $this->pager->getResults();
  }

  public function executeShow(sfWebRequest $request)
  {
	$this->categories = Doctrine_Core::getTable('Categoria')
      ->createQuery('a')
      ->execute();
	$this->categoria_actual = $this->getRoute()->getObject();
	
	$this->pager = new sfDoctrinePager('Dibuix', sfConfig::get('app_max_dibuixos_on_categoria'));
	$this->pager->setQuery($this->categoria_actual->getDibuixosQuery());
	$this->pager->setPage($request->getParameter('page', 1));
	$this->pager->init();
	
	$this->dibuixos = $this->pager->getResults();
  }

  public function executeError404()
  {	
  }
}
